package cn.changhong.user.service.impl;

import cn.changhong.user.dao.AuthenticationMapper;
import cn.changhong.user.model.Authentication;
import cn.changhong.user.model.AuthenticationExample;
import cn.changhong.user.model.vo.AuthenticationVO;
import cn.changhong.user.service.AuthenticationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @Author zz
 * @Date
 **/
@Service
public class AuthenticationServiceImpl implements AuthenticationService {
    @Autowired
    AuthenticationMapper authenticationMapper;
    @Override
    public List<AuthenticationVO> listAuthentication() {
        List<Authentication> list=authenticationMapper.selectByExample(new AuthenticationExample());
        List<AuthenticationVO> listVO=new ArrayList<AuthenticationVO>() ;
        Iterator<Authentication> iterator=list.iterator();
        while (iterator.hasNext()){
            Authentication authentication=iterator.next();
            AuthenticationVO authenticationVO=new AuthenticationVO();
            authenticationVO.setName(authentication.getName());
            authenticationVO.setId(authentication.getId());
            if(authentication.getType() == 1){
                authenticationVO.setType("用户管理");
            }else if(authentication.getType() == 2){
                authenticationVO.setType("设备管理");
            }else if(authentication.getType() == 3){
                authenticationVO.setType("应用管理");
            } else if(authentication.getType() == 4){
                authenticationVO.setType("固件管理");
            }else {
                authenticationVO.setType("首页");
            }
            listVO.add(authenticationVO);
        }
        return listVO;
    }
}
